package cn.tuling.controller;

import cn.tuling.entity.DO.Order;
import cn.tuling.entity.DO.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class OrderController {

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/order/{id}")
    public Order getOrder(@PathVariable Integer id) {
        String url = "http://product-service/product/1";
        Product product = restTemplate.getForObject(url, Product.class);
        return new Order(id, "卡兹克", product, null);
    }
}
